var ReadPasswordBody = {
  template:'<div class="widget-dialog-body">'+
    '<div class="sp-hd">设置阅读密码<span>(密码长度4-50)</span></div>'+
    '<div class="sp-bd">'+
      '<input placeholder="请输入密码" type="password" class="ng-pristine ng-valid ng-touched">'+
      '<input placeholder="再次输入密码" type="password" class="ng-untouched ng-pristine ng-valid">'+
      '</div>'+
      '<div class="error"></div>'+
    '</div>',
    methods:{
      "valid":function(){
        var pwds = $(this.$el).find("input:password");
        var pwd = pwds.eq(0).val();
        var confirmPwd = pwds.eq(1).val();
        if(pwd.length < 4 ){
          $(this.$el).find("div.error").html("密码设置过短");
        }else if(pwd.length > 50 ){
          $(this.$el).find("div.error").html("密码设置过长");
        }else if(pwd !== confirmPwd){
          $(this.$el).find("div.error").html("两次密码不一致");
        }else{
          return pwd;
        }
      }

    }
};
var ReadPasswordDialog = {
  data:function(){
    return {"title":"设置阅读密码"};
  },
  extends:Dialog,
  components:{
    "dialog-body" : ReadPasswordBody
  },
  methods:{
    "doConfirm":function(event){
      var pwd = this.$refs.dialog_body.valid();
      return pwd?true:false;
    },
    "show":function(){
      $(this.$el).find("div.error").html("");
      $(this.$el).find("input:password").val("");
      $(this.$el).show();
    }
  },
  mounted: function () {
    $(this.$el).find("button.btn[disabled]").removeAttr("disabled");
  },
  updated:function(){
    alert(this.id)
  }
}
